import { mapGetters } from 'vuex';

export default {
    computed: {
        ...mapGetters(['token', 'userInfo', 'conf'])
    },

    mounted() {
        let money = Number(uni.getStorageSync('userInfo').subsidiesAmount);
        if (!this.token || money == 0) {
            this.$store.dispatch('getConf').then(res => {
                if (res.isWindow == 1) {
                    return this.$refs['popup-red-package'].open();
                }
            });
        }
    },

    methods: {
        openRP(callback) {
            if (!this.token) {
                return this.$refs['popup-red-package'].open();
            }

            if (this.userInfo.subsidiesAmount == '0.00') {
                return this.$refs['popup-red-package'].open();
            }

            callback();
        }
    }
};
